package com.zj.study.utils.validation.validator.range;


import com.zj.study.utils.validation.annotation.ValidateSupport;
import com.zj.study.utils.validation.annotation.constraint.Range;
import java.math.BigDecimal;
import org.springframework.lang.NonNull;

/**
 * @author 谭耀飞
 * @since 2020.12.0
 */
@ValidateSupport(BigDecimal.class)
public class RangeValidatorForBigDecimal extends AbstractRangeValidator<BigDecimal> {

  @Override
  public boolean compare(@NonNull Range range, @NonNull BigDecimal value) {
    return value.compareTo(new BigDecimal(range.min())) >= 0
        && value.compareTo(new BigDecimal(range.max())) <= 0;
  }

}
